home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / COLMNHDR.PAK / README.TXT < prev   
Text File  |  1997-05-06  |  4KB  |  108 lines

  1. Copyright Borland International
  2. ObjectWindows (C) 1995
  3.  
  4. Title: COLMNHDR Example
  5.  
  6. Keywords: Common Control;Header Controls;TColumnHeader;THeaderItem
  7.  
  8.  
  9. TColumnHeader, an Introduction
  10. ===============================
  11. The ObjectsWindows classes TColumnHeader and THeaderItem can be
  12. used to create, alias and manipulate Header Controls. Header
  13. Controls are windows typically used to 'label' columns of data.
  14. The control contains one or more items, each label a column.
  15. Each Header Item can consists of a string, a bitmapped image and
  16. an associated application-defined 32-bit value.
  17.  
  18.  
  19. Creating a Header Control
  20. =========================
  21. To create a Header Control, simply create a 'TColumnHeader'
  22. object within the constructor of the parent object specifying the
  23. 'parent' and the 'id' of the control.  For example,
  24.  
  25.    TMyWindow::TMyWindow() {
  26.      // ...
  27.      TColumnHeader* hdrCtl = new TColumnHeader(this, ID_XX);
  28.    }
  29.  
  30. When constructed within the constructor of the parent object, it
  31. is not necessary to invoke the 'Create' method of the
  32. 'TColumnHeader' object. The 'AutoCreate' feature of
  33. ObjectWindows will ensure that the control is created once the
  34. parent object is created. However, if you are constructing the
  35. TColumnHeader object after its parent has been created, you will
  36. also need to invoke it's 'Create' method.
  37.  
  38. NOTE: Although you can specify the screen coordinates of the
  39. control, these parameters are typically left out in favour of
  40. the 'Layout' capabilities of the 'TColumnHeader' object; more on
  41. this later.
  42.  
  43.  
  44. Adding items to a Header Control
  45. ================================ 
  46. Once the control has been created (NOTE: It's important to
  47. distinguish between the construction of the C++ object and the
  48. creation of the actual underlying window, you can add items
  49. using the 'Add' or 'Insert' methods of the TColumnHeader class.
  50.  
  51. The 'THeaderItem' class holds information about an item of a
  52. Header Control. To add/insert an item you must first construct a
  53. 'THeaderItem' instance. After initializing the 'THeaderItem' instance,
  54. you can invoke the 'Add' or 'Insert' method of the 'TColumnHeader' object.
  55. For example:
  56.  
  57.   THeaderItem item("&Name of Employee");
  58.   hdrCtl->Add(item);
  59.  
  60.  
  61. Responding to Header Control Notification Messages
  62. ====================================================
  63. The Header Control sends notification messages to its parent
  64. window whenever user manipulates the Header Control. For
  65. example, if the user clicks an item, the control sends a
  66. HDN_ITEMCLICK notification message.
  67.  
  68. ObjectWindows provides several macros which can be used in the
  69. definition of a Message Response Table allowing a member
  70. function to be invoked when particular notification messages are
  71. received by the parent. The following list the macros pertinent
  72. to the Header Control:
  73.  
  74.   EV_HDN_BEGINTRACK(id, method)       // User starts dragging divider
  75.   EV_HDN_DIVIDERDBLCLICK(id, method)  // User double clicked divider
  76.   EV_HDN_ENDTRACK(id, method)         // User ends drag operation
  77.   EV_HDN_ITEMCHANGED(id,method)       // Attribute of an item changed
  78.   EV_HDN_ITEMCHANGING(id,method)      // Attribute about to change
  79.   EV_HDN_ITEMCLICK(id, method)        // User clicked on item
  80.   EV_HDN_TRACK(id, method)            // User dragged a divider
  81.  
  82.  
  83. Sizing and Positioning a Header Control
  84. ========================================
  85. A Header Control is typically docked to the upper side of its
  86. parent's client area. The control provides an API which allows
  87. the control to specify a desired size and position within the
  88. boundary of a specified rectangle. The 'bool Layout(TRect&
  89. boundingRect, WINDOWPOS& winPos)' method can be used to retrieve
  90. the appropriate size and position values in a WINDOWPOS
  91. structure.
  92.  
  93. The overloaded 'bool Layout(uint swpFlags = 0)' method provides
  94. an higher abstraction of this API: the desired size of the
  95. control is retrieved specifying the client area of its parent as
  96. the bounding rectangle and the control is then repositioned
  97. accordingly. The 'swpFlags' are used when call 'SetWindowPos' to
  98. reposition the control.
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.